<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>添加药品</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" type="text/css" href="../common/layui/css/layui.css" media="all">
    <link rel="stylesheet" type="text/css" href="../common/bootstrap/css/bootstrap.css" media="all">
    <link rel="stylesheet" type="text/css" href="../common/global.css" media="all">
    <link rel="stylesheet" type="text/css" href="../css/personal.css" media="all">
    <style>
        #img{
             position: absolute;
            left: 0;
              top: 0;
            opacity: 0;
        }
    </style>
</head>
<body>
<section class="layui-larry-box">
    <div class="larry-personal">
        <header class="larry-personal-tit">
            <span>药品添加</span>
        </header><!-- /header -->
        <div class="larry-personal-body clearfix">
            <form class="layui-form col-lg-5" action="" method="post" id="em_info">


                <div class="layui-form-item">
                    <label class="layui-form-label">药品名称</label>
                    <div class="layui-input-block">
                        <input type="text" id="dr_name" name="name"  autocomplete="off" class="layui-input" value="">
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">有效期</label>
                    <div class="layui-input-block">
                        <input type="text" id="dr_validity" name="validity"  autocomplete="off" class="layui-input" value="">
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">剂型</label>
                    <div class="layui-input-inline">
                        <select name="dosageform" class="newsLook" lay-filter="browseLook" id="dr_dosageform">
                            <option value="颗粒" >颗粒</option>
                            <option value="片剂" >片剂</option>
                            <option value="溶液" >溶液</option>
                            <option value="气体" >气体</option>
                        </select>
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">所属公司</label>
                    <div class="layui-input-block">
                        <input type="text" id="dr_storename" name="storename"  autocomplete="off" class="layui-input" placeholder="">
                        <!--添加员工默认在职-->
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">药品价格</label>
                    <div class="layui-input-block">
                        <input type="text" id="dr_price" name="price"  autocomplete="off" class="layui-input" placeholder="">
                        <!--添加员工默认在职-->
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">药品销量</label>
                    <div class="layui-input-block">
                        <input type="text" id="dr_sales" name="sales"  autocomplete="off" class="layui-input" placeholder="">
                    </div>
                </div>


                <div class="layui-form-item">
                    <label class="layui-form-label">药品图片</label>
                    <div class="layui-input-block">
                        <label for="img">
                            <input type="button" id="btn" value="请上传识别图像" class="layui-btn layui-btn-normal"><span name="picture" id="text"></span>
                            <input type="file" name="img" id="img"><br /><br />
                        </label>
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">类型</label>
                    <div class="layui-input-inline">
                        <select name="drugtypeid" class="newsLook" lay-filter="browseLook" id="drug_type">
                            <option value="1" >补益类用药</option>
                            <option value="2" >维生素钙</option>
                            <option value="3" >消化系统</option>
                            <option value="4" >感冒用药</option>
                            <option value="5" >儿科用药</option>
                            <option value="6" >皮肤用药</option>
                            <option value="7" >五官用药</option>
                            <option value="8" >呼吸系统</option>
                            <option value="9" >妇科用药</option>
                            <option value="10" >男科用药</option>
                            <option value="11" >止痛镇痛</option>
                            <option value="12" >风湿骨外伤用药</option>
                        </select>
                    </div>
                </div>



                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button class="layui-btn" type="button" onclick="adddurg()" lay-filter="demo1">立即提交</button>
                        <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                    </div>
                </div>
            </form>
        </div>
    </div>


</section>
<script type="text/javascript" src="../common/layui/lay/dest/layui.all.js"></script>
<script type="text/javascript" src="../js/login.js"></script>
<script type="text/javascript" src="../jsplug/jparticle.jquery.js"></script>
<script type="text/javascript" src="../common/layui/layui.js"></script>
<script type="text/javascript" src="../jsplug/ajaxfileupload.js"></script>
<script src="//unpkg.com/layui@2.7.4/dist/layui.js"></script>
<script src="../js/token.js"></script>
<script type="text/javascript">

            $("#img").change(function () {
                var filePath = $("#img").val();
                var arr=filePath.split('\\');
                var fileName = arr[arr.length-1];
                $("#text").html(fileName);
            })


    /*添加药品操作*/ /*获取图片文件名字:alert( $("#text").text())*/
    function adddurg(){
       var name=$("#dr_name").val()
        var validity=$("#dr_validity").val()
        var dosageform=$("#dr_dosageform").val()
        var  storename=$("#dr_storename").val()
        var  price=$("#dr_price").val()
        var  sales=$("#dr_sales").val()
        var drugtypeid=$("#drug_type").val()
        $.ajaxFileUpload({
                url: '../../drug/fileUpload', //用于文件上传的服务器端请求地址   调用后端接口（interface）
                fileElementId: 'img', //文件上传域的ID
                dataType: 'json', //返回值类型 一般设置为json
                data: {
                    name:name,
                    validity:validity,
                    dosageform:dosageform,
                    storename:storename,
                    price:price,
                    sales:sales,
                    drugtypeid:drugtypeid,
                },
                success: function (data) {
                    layer.confirm('药品添加成功，前往查看！', {
                        icon: 1,        //会出现正确的图片
                        btn: ['好']     //按钮
                    }, function(){
                        window.location.href="drug_table.html";//点击“好”后进行跳转
                    });
                }
            }
        )
    }

    /**
     * 修改员工信息
     */

</script>
</body>
</html>